{% extends 'publisher_list.html' %}

{% block pub_active %}

{% endblock %}

{% block author_active %}
    active
{% endblock %}


{% block main %}

    <h2 class="sub-header">作者列表 </h2>
    <a class="btn btn-primary btn-sm" href="/author_add/">新增</a>
    <div class="table-responsive">
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>序号</th>
                <th>id</th>
                <th>作者姓名</th>
                <th>代表作</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for author in all_author %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ author.pk }}</td>
                    <td>{{ author.name }}</td>
                    <td>
                        {% for book in author.books.all %}
                            《{{ book.name }}》
                        {% endfor %}

                    </td>
                    <td>
                        <a class="btn btn-danger btn-sm" href="{% url 'del' 'author' author.pk %}">删除</a>
                        <a class="btn btn-primary btn-sm" href="/author_edit/?id={{ author.pk }}">修改</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

{% endblock %}

